package MapReduce.reduceJoin;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class reduceJoinMain {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        // 1 获取Job
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        // 2 获取jar包路径
        job.setJarByClass(reduceJoinMain.class);

        // 3 关联Mapper和Reducer
        job.setMapperClass(reduceJoinMapper.class);
        job.setReducerClass(reduceJoinReducer.class);

        // 4 设置map输出的K V类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(TableBean.class);

        // 5 设置最终的输出K V类型
        job.setOutputKeyClass(TableBean.class);
        job.setOutputValueClass(NullWritable.class);

        // 6 设置输入输出路径
        FileInputFormat.addInputPath(job, new Path("D:\\中国科学院大学硕士\\学习类文件夹\\BigDataDev\\Input\\inputtable"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\中国科学院大学硕士\\学习类文件夹\\BigDataDev\\Output\\output3"));

        // 7 提交Job
        boolean waitForCompletion = job.waitForCompletion(true);
        System.exit(waitForCompletion ? 0 : 1);
    }
}
